package com.qijian.maindata.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.qijian.common.annotation.Excel;
import com.qijian.common.annotation.Excels;
import com.qijian.maindata.domain.LineProcess;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 工艺对象
 *
 * @author qijian
 * @date 2021-09-03
 */

@EqualsAndHashCode(callSuper = true)
@Data
@ToString
public class LineProcessVo extends LineProcess {
    @Excels({
            @Excel(name = "物料编号", targetAttr = "itemCode", sort = 2),
            @Excel(name = "图号", targetAttr = "drawingNo", sort = 3),
            @Excel(name = "件号", targetAttr = "drawingNo", sort = 4),
            @Excel(name = "名称", targetAttr = "itemName", sort = 5)
    })
    private BomDetailVo bomDetail;

    @Excel(name = "工时", sort = 9)
    private BigDecimal workWaitTime;

    @Excel(name = "数量", sort = 11)
    private Integer count;

    @Excel(name = "分配班组", sort = 17)
    private String workTeam;

    private Integer level;

    private Integer dictSort;

    @JsonIgnore
    @TableField(exist = false)
    private LocalDateTime startTime;
    @JsonIgnore
    @TableField(exist = false)
    private LocalDateTime endTime;
    @JsonIgnore
    @TableField(exist = false)
    private Long bomDetailId;



    public BigDecimal getWorkWaitTime() {
        if (this.getWorkTime() == null) {
            return this.getWaitTime();
        } else if (this.getWaitTime() == null)
            return this.getWorkTime();
        return this.getWorkTime().add(this.getWaitTime());
    }

    public BomDetailVo getBomDetail() {
        if (bomDetail == null)
            bomDetail = new BomDetailVo();
        return bomDetail;
    }
}
